<#include "../../layout/default.ftl">
<@layout>
<ul class="breadcrumb mt20">
    <li><a href="#">友情链接管理</a> <span class="divider">/</span></li>
    <li class="active">新增友情链接</li>
</ul>
<div class="mt20">
    网站名称：<input type="text" id="title" value="${(o.title)!""}"><br>
    网站链接：<input type="text" id="url" value="${(o.url)!""}" style="width: 500px;"><br>
    排序权重：<input type="text" id="weight" value="${(o.weight)!""}"> <span class="orange">0~99之间，值越大，排在越靠前的位置，默认是0</span><br>
    <input type="button" value=" 保存 " id="saveBtn" class="btn">
    <input type="button" value=" 清空 " id="clearBtn" class="btn">
</div>
<script type="text/javascript">
    $(function () {
        active_menu("blogrollMenu");
        $("#clearBtn").click(function () {
            $("input[type=text]").val("");
        });
        $("#saveBtn").click(function () {
            var title = $("#title").val();
            var url = $("#url").val();
            var weight = $("#weight").val();
            if (title.length == 0) {
                errMsg("网站标题不能为空");
                return false;
            }
            if (url.length == 0) {
                errMsg("网站链接不能为空");
                return false;
            }

            jQuery.post("${ctx}/admin/blogroll/save", {"title": title, "url": url, "weight": weight, "id": "${(o.title)!"-1"}"}, function (json) {
                if (json.msg.length > 0) {
                    errMsg(json.msg);
                } else {
                    okMsg("保存成功");
                }
            });

        });
    });
</script>
</@layout>